package com.codequirks.xmlbeanutils;

import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Provides an interface through which {@link XmlDynaBean} accesses various
 * {@link Node} and {@link Attr} properties.
 * <p/>
 * This interface can be implemented in order to provide functionality and
 * tooling during the XmlDynaBean initialization. By default, {@link DefaultNodePropertyAccessor}
 * is used, however {@link LegacyNodePropertyAccessor} is also provided for working with legacy
 * parsers.
 *
 * @author Travis Calder <travis.calder@gmail.com>
 * @since 1.0.1
 */
public interface NodePropertyAccessor {
    /**
     * Gets all children of a provided node.
     * @param node Parent node
     * @return All children of the parent node
     */
    NodeList getAllChildren(Node node);

    /**
     * Gets all attributes of a provided node.
     * @param node Parent node
     * @return All attributes of the parent node
     */
    NamedNodeMap getAllAttributes(Node node);

    /**
     * Gets the name of a node
     * @param node Parent node
     * @return Name of parent node
     */
    String getNodeName(Node node);

    /**
     * Gets the value of an attribute
     * @param attribute Parent attribute
     * @return Value of parent attribute
     */
    String getAttributeContents(Attr attribute);

    /**
     * Gets the text content of a node
     * @param node Parent node
     * @return Text content of parent node
     */
    String getNodeText(Node node);
}
